// 编辑数据
module.exports = function (app, mongoose) {
  app.post("/edit", function (req, res) {
    var Patient = mongoose.model("Patient");
    Patient.findOne({
      _id: req.body._id
    }, function (err, docs) {
      if (err) {
        console.log("err:", err);
        res.json({
          state: 0,
          msg: "数据库错误"
        });
        return
      } else {
        docs.name = req.body.name,
          docs.createName = req.body.createName,
          docs.age = req.body.age,
          docs.sex = req.body.sex,
          docs.websource = req.body.websource,
          docs.zhenduan = req.body.zhenduan,
          docs.zxdf = req.body.zxdf,
          docs.phone = req.body.phone,
          docs.doctor = req.body.doctor,
          docs.region = req.body.region,
          docs.date = req.body.date,
          docs.qq = req.body.qq,
          docs.msgsource = req.body.msgsource,
          docs.weixin = req.body.weixin,
          docs.urgency = req.body.urgency,
          docs.buwei = req.body.buwei,
          docs.createTime = req.body.createTime,
          docs.lastTime = req.body.lastTime,
          docs.zz = req.body.zz,
          docs.beianren = req.body.beianren,
          docs.status = req.body.status,
          docs.regionKey = req.body.regionKey,
          docs.textarea = req.body.textarea
        docs.ip = req.ip.split(":")[3]
        docs.save();
        res.json({
          status: 1,
          msg: "录入成功"
        });
        return
      }
    })
  })
}
